﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
''' <summary>
''' 用于储存接受点是否选中的类
''' </summary>
''' <remarks></remarks>
<Serializable()> Public Class ReceptorSelected
    Implements ICloneable
    ''' <summary>
    ''' 离散点数组是否选中
    ''' </summary>
    ''' <remarks></remarks>
    Private m_DiscCartsSlected(-1) As DiscCart
    ''' <summary>
    ''' 嵌套的网格是否选中
    ''' </summary>
    ''' <remarks></remarks>
    Private m_SubGridCartSlected(-1) As GridCart

    ''' <summary>
    ''' 离散点数组是否选中
    ''' </summary>
    ''' <remarks></remarks>
    Property DiscCartsSlected() As DiscCart()
        Get
            Return Me.m_DiscCartsSlected
        End Get
        Set(ByVal value As DiscCart())
            Me.m_DiscCartsSlected = value
        End Set
    End Property
    ''' <summary>
    ''' 嵌套的网格是否选中
    ''' </summary>
    ''' <remarks></remarks>
    Property SubGridCartSlected() As GridCart()
        Get
            Return Me.m_SubGridCartSlected
        End Get
        Set(ByVal value As GridCart())
            Me.m_SubGridCartSlected = value
        End Set
    End Property
    ''' <summary>
    ''' 返回用户选中的关心点的个数
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetSelectedDisCartCount() As Integer
        Dim Count As Integer = 0
        For i As Integer = 0 To Me.m_DiscCartsSlected.Length - 1
            If Me.m_DiscCartsSlected(i).Selected = True Then
                Count += 1
            End If
        Next
        Return Count
    End Function
    ''' <summary>
    ''' 返回用户选中的网格点的个数
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetSelectedGridCount() As Integer
        Dim Count As Integer = 0
        For i As Integer = 0 To Me.m_SubGridCartSlected.Length - 1
            If Me.m_SubGridCartSlected(i).Selected = True Then
                Count += 1
            End If
        Next
        Return Count
    End Function
    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj As New ReceptorSelected
        '嵌套网格
        ReDim obj.m_SubGridCartSlected(Me.m_SubGridCartSlected.Length - 1)
        For i As Integer = 0 To Me.m_SubGridCartSlected.Length - 1
            obj.m_SubGridCartSlected(i) = Me.m_SubGridCartSlected(i).Clone
        Next
        '关心点
        ReDim obj.m_DiscCartsSlected(Me.m_DiscCartsSlected.Length - 1)
        For i As Integer = 0 To Me.m_DiscCartsSlected.Length - 1
            obj.m_DiscCartsSlected(i) = Me.m_DiscCartsSlected(i).Clone
        Next
        Return obj
    End Function
    <OnDeserializing()> _
   Friend Sub OnDeserializingMethod(ByVal context As StreamingContext)

    End Sub

    <OnDeserialized()> _
    Friend Sub OnDeserializedMethod(ByVal context As StreamingContext)

    End Sub
End Class
